const log4js = require("../config/log4/log4");

const logger = log4js.getLogger(process.env.LOG_CATEGORY);

module.exports = (req, res, next) => {
    let origin = req.get("Origin"),
        {path, method, query, body, params} = req;
    logger.info(`[LOGS] URL: ${origin}${path} ${method}`)
    if(method === 'POST') {
        logger.info(`[LOGS] body:${JSON.stringify(body)}`)
    } else {
        logger.info(`[LOGS] query:${JSON.stringify(query)}`)
    }
    logger.info(`[LOGS] params:${JSON.stringify(params)}`)
    console.log('--------------------------------------------------------------------------')
    next();
}
